package com.sihan.framework.etm.common.util;

import java.net.URLEncoder;
import java.util.Enumeration;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
 * 将request参数集合转换为map
 * @author 
 * @param request
 * @return map
 */
public class RequestUtil {
	public HashMap<String,Object> getRequestMap(HttpServletRequest request){
		HashMap<String,Object> map = new HashMap<String,Object>();
		Enumeration<String> enu=request.getParameterNames();  
			while(enu.hasMoreElements()){  
			String paraName= enu.nextElement();
			map.put(paraName, request.getParameter(paraName));
		} 
		return map;
	}
	
	public static HttpServletResponse getResponse(HttpServletResponse response,HttpServletRequest request,String name) throws Exception{
	   String fileName="";
	   fileName = URLEncoder.encode(name,"UTF8");
	   response.reset();
	   response.setContentType("application/vnd.ms-excel;charset=UTF-8");//application/vnd.ms-excel告诉浏览器要下载的是个excel
	   response.setHeader("Content-Disposition", "attachment;filename="+fileName+".xls");//请求头设置，Content-Disposition为下载标识，attachment标识以附件方式下载
	   return response;
	}
}
